//
//  FansAndAttentionCell.m
//  OnionHome
//
//  Created by fengjie on 2019/9/14.
//  Copyright © 2019 FengJie. All rights reserved.
//

#import "FansAndAttentionCell.h"

@interface FansAndAttentionCell ()
/**左边图标*/
@property (nonatomic,strong)UIImageView*leftImage;
/**名称*/
@property (nonatomic,strong)UILabel*nameLabel;
/**介绍*/
@property (nonatomic,strong)UILabel*introduceLb;
/**粉丝数量*/
@property (nonatomic,strong)UILabel*fansNumber;
/**是否关注按钮*/
@property (nonatomic,strong)UIButton*guanzhuBtn;
@end

@implementation FansAndAttentionCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style  reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;

        [self createUI];
    }
    return self;
}
-(void)createUI{
//    self.backgroundColor = RGB(236, 239, 243);
    
    [self addSubview:self.leftImage];
    [self addSubview:self.nameLabel];
    [self addSubview:self.introduceLb];
    [self addSubview:self.fansNumber];
    [self addSubview:self.guanzhuBtn];
    
    [self.leftImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.mas_equalTo(16);
        make.bottom.mas_equalTo(-16);
        make.width.height.mas_equalTo(64);
    }];
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.leftImage.mas_right).offset(10);
        make.top.mas_equalTo(self.leftImage);
    }];
    [self.introduceLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.leftImage.mas_right).offset(10);
        make.top.mas_equalTo(self.nameLabel.mas_bottom).offset(4);
    }];
    [self.fansNumber mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.leftImage.mas_right).offset(10);
        make.top.mas_equalTo(self.introduceLb.mas_bottom).offset(4);
    }];
    
    [self.guanzhuBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.leftImage);
        make.right.mas_equalTo(-16);
        make.width.mas_equalTo(72);
        make.height.mas_equalTo(28);
    }];

}
-(void)setModel:(FansAndAttentionModel *)model{
    _model = model;
    self.leftImage.image = IMAGE_NAMED(model.userIcon);
    self.nameLabel.text = model.userName;
    self.introduceLb.text = model.userType;
    self.fansNumber.text = [NSString stringWithFormat:@"粉丝数:%@",model.fansNum];
    self.guanzhuBtn.selected = model.isGuanzhu;
}
#pragma mark --懒加载
-(UIImageView*)leftImage{
    if(!_leftImage){
        _leftImage=[UIImageView new];
        _leftImage.layer.cornerRadius = 32;
        _leftImage.image = IMAGE_NAMED(@"userIconDefut");
        _leftImage.layer.masksToBounds = YES;
    }
    return _leftImage;
}
-(UILabel*)nameLabel{
    if(!_nameLabel){
        _nameLabel=[UILabel new];
        _nameLabel.textColor = UIColorFromRGB(0x273323);
        _nameLabel.font = BOLDSYSTEMFONT(16);
        _nameLabel.text = @"大鲨鱼";
    }
    return _nameLabel;
}
-(UILabel*)introduceLb{
    if(!_introduceLb){
        _introduceLb=[UILabel new];
        _introduceLb.textColor = UIColorFromRGB(0x959E97);
        _introduceLb.font = BOLDSYSTEMFONT(12);
        _introduceLb.text = @"美食制作领域达人";
    }
    return _introduceLb;
}
-(UILabel*)fansNumber{
    if(!_fansNumber){
        _fansNumber=[UILabel new];
        _fansNumber.textColor = UIColorFromRGB(0x959E97);
        _fansNumber.font = BOLDSYSTEMFONT(12);
        _fansNumber.text = @"粉丝数：1";
    }
    return _fansNumber;
}
-(UIButton*)guanzhuBtn{
    if(!_guanzhuBtn){
        _guanzhuBtn=[UIButton buttonWithType:UIButtonTypeCustom];
        [_guanzhuBtn setTitle:@"相互关注" forState:UIControlStateSelected];
        [_guanzhuBtn setTitle:@"关注" forState:UIControlStateNormal];

        [_guanzhuBtn setTitleColor:UIColorFromRGB(0x959E97) forState:UIControlStateSelected];
        [_guanzhuBtn setTitleColor:UIColorFromRGB(0xFFFFFF) forState:UIControlStateNormal];
        
        [_guanzhuBtn setBackgroundImage:[UIImage createImageWithColor:UIColorFromRGB(0x009966)] forState:UIControlStateNormal];
        [_guanzhuBtn setBackgroundImage:[UIImage createImageWithColor:RGB(236, 239, 243)] forState:UIControlStateSelected];

        _guanzhuBtn.layer.borderColor = UIColorFromRGB(0x959E97).CGColor;
        _guanzhuBtn.layer.borderWidth =1;
        
        _guanzhuBtn.titleLabel.font = SYSTEMFONT(12);
        
        _guanzhuBtn.selected = YES;

    }
    return _guanzhuBtn;
}
@end
